package com.ny.service.impl;

import com.ny.dao.ProductDao;
import com.ny.dao.impl.ProductDaoImpl;
import com.ny.entity.Product;
import com.ny.service.ProductService;

import java.sql.SQLException;
import java.util.List;

public class ProductServiceImpl implements ProductService {
    private ProductDao  productDao = new ProductDaoImpl();

    public ProductServiceImpl() throws SQLException, ClassNotFoundException {
    }

    @Override
    public List<Product> findAllProduct() throws SQLException {
        return productDao.findAllProduct();
    }

    @Override
    public Product findProductById(int productId) throws SQLException {
        return productDao.findProductById(productId);
    }

    @Override
    public boolean updateProductStock(int productId, int number) throws SQLException {
            return productDao.updateProductStock(productId, number);
        }


    @Override
    public int updateStudentPassword(int studentId, String studentPassword) throws SQLException {
        return productDao.updateStudentPassword(studentId, studentPassword);
    }

    @Override
    public int addProduct(Product product) throws SQLException {
        return productDao.addProduct(product);
    }

    @Override
    public boolean deleteProduct(int deleteId) throws SQLException {
        return productDao.deleteProduct(deleteId);
    }
}
